package OurGame;

import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import javax.swing.*;

public class Ro {
	int x, dx, y, nx, nx2, left, dy;
	Image still, jump, reverse;

	int ammo = 100;

	static ArrayList bullets;// Holds number of bullets on screen

	ImageIcon s = new ImageIcon("Image/Ro.png");
	ImageIcon j = new ImageIcon("Image/Ro.png");
	ImageIcon l = new ImageIcon("Image/Ro.png");

	public static ArrayList getBullets() {
		return bullets;
	}

	public Ro() {
		// ImageIcon i = new ImageIcon("C:/Users/Public/Pictures/vanille1.png");

		x = 75;
		left = 200;
		nx = 0;
		nx2 = 685;
		y = 565;
		still = s.getImage();
		bullets = new ArrayList();
	}

	public Rectangle getBounds() {
		return new Rectangle(left, y, 100, 81);
	}

	public void fire()// Method to run when when fired
	{

		// System.out.println(bullets.size() + " " + ammo);
		// if (ammo > 0) {
		// ammo--;
		// // Create a new bullet object and add it to
		// // array "list" of all bullets on screen.
		// Bullet z = new Bullet((left + 60), (y + 154 / 2), );
		// bullets.add(z);
		// }
	}

	public void move() {
		if (dx > -1) {
			if (left + dx <= (500 - 100))
				left += dx;
			else {
//				dx = -1;
//				left = left + dx;
			}
		} else {
			if (left + dx > -20)
				left = left + dx;
			else {
//				dx = 1;
//				left = left + dx;
			}
		}
	}

	public void move1() {
		if (dx != -1) {
			if (left + dx <= 150)
				left += dx;
			else {
				x = x + dx;
				nx2 = nx2 + dx;
				nx = nx + dx;
			}
		} else {
			if (left + dx > 0)
				left = left + dx;
		}
	}

	public int getX() {
		return x;
	}

	public int getLeft() {
		return left;
	}

	public int getY() {
		return y;
	}

	public int getnX() {
		return nx;
	}

	public int getnX2() {
		return nx2;
	}

	public int getdx() {
		return dx;
	}

	public Image getImage() {
		return still;
	}

	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_LEFT) {
			dx = -2;
			still = l.getImage();
		}
		if (key == KeyEvent.VK_RIGHT) {
			dx = 2;
			still = s.getImage();
		}

		// if (key == KeyEvent.VK_SPACE) {
		// fire();
		// }

		// if (key == KeyEvent.VK_UP) {
		// dy = 1;
		// still = j.getImage();
		// }
	}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		if (key == KeyEvent.VK_LEFT)
			dx = 0;
		if (key == KeyEvent.VK_RIGHT)
			dx = 0;
		if (key == KeyEvent.VK_UP) {
			dy = 0;
			still = s.getImage();
		}
	}
}
